package models;

import java.sql.Date;
import java.util.*;
import javax.persistence.*;
import javax.validation.Constraint;

import play.api.mvc.Session;
import play.db.ebean.*;
import play.db.ebean.Model.Finder;
import play.data.format.*;
import play.data.validation.*;

@Entity
public class edu_coursesstudents extends Model{

	@Id
	public int relation_id;
	
	public int user_id;
	
	public int course_id;
	
	public int registration_date;
	
	public static Finder<Long,edu_coursesstudents> find = new Finder<Long,edu_coursesstudents>(Long.class, edu_coursesstudents.class);
	
	public static List<edu_coursesstudents> findById(int userId)
	{
		return edu_coursesstudents.find.where().eq("user_id",userId).findList();
	}
	
	
	public static edu_coursesstudents findByCourseNStudentId(int course_id, int user_id) {
        return edu_coursesstudents.find.where().eq("course_id", course_id).eq("user_id", user_id).findUnique();
    }	
	
	public static void dropCourse(int course_id, int user_id) {
        edu_coursesstudents.find.where().eq("course_id", course_id).eq("user_id", user_id).findUnique().delete();
    }	
}
